<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='抓取文章',active='catchArticle'">
<header th:replace="back/header::headerFragment(${title},${active})"></header>
<meta th:name="_csrf" th:content="${_csrf.token}"/>
<!-- 默认的header name是X-CSRF-TOKEN -->
<meta th:name="_csrf_header" th:content="${_csrf.headerName}"/>

<style>
    .topbar {
        height: 70px;
    }


    #i1 {
        width: 260px;
        height: 30px;
        float: left;
    }

    #i2 {
        width: 54px;
        height: 33.6px;
        float: left;
    }

    .panel-body {
        height: 133.6px;

    }

    #i5 {
        width: 260px;
        height: 30px;
        float: left;
    }

    #i6 {
        width: 54px;
        height: 33.6px;
        float: left;
    }

</style>
<body class="fixed-left">
<div id="wrapper">
    <div th:replace="back/header::header-body"></div>
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="page-title">抓取文章</h4>
                    </div>
                    <!--                                        内容-->

                    <div class="panel-body">

                        <div class="row">


                            <div class="col-md-6">
                                <div id="p1" class="panel panel-color panel-purple">
                                    <div class="panel-heading">
                                        <h1 class="panel-title" style="line-height:20px;">抓取指定文章</h1>
                                    </div>
                                    <div class="panel-body">
                                        <form id="cform" method="post" href="#" autocomplete="off">

                                            <div id="i1">
                                                <select id="ss" name="type" th:each="select:${selects}"
                                                        th:value="${select}">
                                                    <option th:text="${select}" th:value="${select}"></option>
                                                </select>
                                                <textarea id="iurl" name="url" required
                                                          placeholder="输入具体文章url"></textarea>
                                            </div>

                                            <div id="i2">
                                                <button type="button" onclick="startCatch1()"
                                                        class="btn btn-success waves-effect waves-light m-l-10">
                                                    开始抓取
                                                </button>
                                            </div>
                                        </form>
                                    </div>

                                </div>
                            </div>


                            <div class="col-md-6">
                                <div class="panel panel-color panel-purple">
                                    <div class="panel-heading">
                                        <h1 class="panel-title" style="line-height:20px;">抓取指定模块文章</h1>
                                    </div>
                                    <div class="panel-body">
                                        <form method="post" href="#" autocomplete="off">

                                            <div id="i5">
                                                <select id="ss5" name="type" th:each="select:${selects}"
                                                        th:value="${select}">
                                                    <option th:text="${select}" th:value="${select}"></option>
                                                </select>
                                                <textarea id="iurl5" name="url" required
                                                          placeholder="输入具体模块url"></textarea>
                                            </div>

                                            <div id="i6">
                                                <button type="button" onclick="startCatch2()"
                                                        class="btn btn-success waves-effect waves-light m-l-10">
                                                    开始抓取
                                                </button>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>


                        </div>
                    </div>


                </div>
                <div th:replace="back/footer :: footer-content"></div>
            </div>
        </div>
    </div>
</div>


<div th:replace="back/footer :: footer"></div>

</body>


<script th:src="@{/assets/js/jquery.min.js}"></script>
<!--  alert弹框插件，必须要有jQuery的支持-->
<script type="text/javascript" th:src="@{/assets/js/alertJS/alert.min.js}"></script>
<script>
    function startCatch1() {
        $.ajax({
            url: '/catchArticle/catchArticle',
            data: {
                "url": $("#iurl").val(),
                "type": $("#ss").val()
            },
            success: function (data) {
                var json = JSON.parse(data);
                if (json.result == 200) {
                    $.alert("抓取文章数据成功！！！");
                } else {
                    // alert('抓取数据失败！！！')
                    $.alert('抓取文章数据失败！！！');
                }
            }
        });

    }

    function startCatch2() {
        $.ajax({
            url: '/catchArticle/catchModelArticle',
            data: {
                "url": $("#iurl5").val(),
                "type": $("#ss5").val()
            },
            success: function (data) {
                var json = JSON.parse(data);
                if (json.result == 200) {
                    $.alert("抓取模块数据成功！！！");
                } else {
                    // alert('抓取数据失败！！！')
                    $.alert('抓取模块数据失败！！！');
                }
            }
        });

    }


</script>


</html>